#include <cstdio>
char tmp[55];

int a[55][55]={0};

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;i++){
        scanf("%s",tmp);
        for(int j=0;j<m;j++){
            if (tmp[j] == 'B')
                a[i][j]=1;
        }
    }
    int ok=1;
    int dan=0;
    for (int i=0;i<n;i++){
        int cnt=0;
        for (int j=1;j<m;j++){
            if(a[i][j-1] == 0 && a[i][j] == 1){
                cnt++;
            }
            if(a[i][j-1] == 0 && a[i][j] == 1 && a[i][j+1]==0){
                dan++;
            }
        }
        if(cnt < 2){
            ok=0;

        }
        else{
            ok=1;
            break;
        }
    }
    for (int i=0;i<n;i++){
        int cnt=0;
        for (int j=1;j<m;j++){
            if(a[j-1][i] == 0 && a[j][i] == 1){
                cnt++;
            }
            if (a[j-1][i] == 0 && a[j][i] == 1 && a[j+1][i]==0){
                dan++;
            }
        }
        if(cnt < 2){
            ok=1;
        }
        else{
            ok=1;
            break;
        }
    }
    if (ok == 0 || dan == 1)
        printf("YES\n");
    else
        printf("NO\n");
}
